/**=============================================================================
# Author: wanghongfu -1583505981@qq.com
#
# Last modified: 2017-03-17 09:47
#
# Filename: Subject.java
#
# Description: 
#
=============================================================================*/
import java.util.*;
public class Subject {
	
	private List<Observer> observers=new ArrayList<Observer>();
	private int state;

	public int getState(){
		return state;
	}

	public void setState(int state){
		this.state=state;
		notifyAllObservers();
	}

	public void attach(Observer observer){
		observers.add(observer);
	}

	public void notifyAllObservers(){
		for (Observer observer : observers ) {
			observer.update();
		}
	}
}
